package com.muyu.product.domain.model;

import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.req.AttributeGroupSaveReq;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.List;



/**
 * @author DongZl
 * @description: 属性组添加模型
 * @Date 2024-2-28 下午 03:16
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class AttributeGroupSaveModel extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /** 组名称 */
    private String name;

    /** 状态 */
    private String states;

    /**
     * 属性ID集合
     */
    private List<Long> attributeIdList;

    public static AttributeGroupSaveModel saveReqBuild (AttributeGroupSaveReq req){
        return AttributeGroupSaveModel.builder()
                .name(req.getName())
                .states(req.getStates())
                .attributeIdList(req.getAttributeIdList())
                .build();
    }

    public AttributeGroup buildAttributeGroup () {
        return AttributeGroup.builder()
                .name(this.getName())
                .states(this.getStates())
                .build();
    }
}
